//
//  WebViewController.m
//  NetPhone
//
//  Created by intel intel on 12-5-9.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "WebViewController.h"

@implementation WebViewController
@synthesize content;

- (id)initWithUrl:(NSString *)_url
{
    self = [super init];
    if (self) {
        url = [_url retain];
    }
    return self;
}


// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad
{
    [super viewDidLoad];

    webView = [[[UIWebView alloc]initWithFrame:CGRectMake(0, 0, 320, self.view.frame.size.height-49-44)]autorelease];
    webView.delegate = self;
    [self.view addSubview:webView];
 
	HUD = [[[MBProgressHUD alloc] initWithView:self.view]autorelease];
    HUD.removeFromSuperViewOnHide = YES;
	[self.view addSubview:HUD];
	[HUD setLabelFont:[UIFont systemFontOfSize:12]];
	[HUD setLabelText:@"正在加载,请稍候..."];
	[HUD show:YES];

    if([content length] > 0){
        [webView loadHTMLString:content baseURL:nil];
    }else{
        [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]]];
    }

}

- (void)webViewDidFinishLoad:(UIWebView *)webView
{
    [HUD hide:YES];
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}


-(void)dealloc
{
    [url release];
    [super dealloc];
}

@end
